package ph.com.gs3.formalistics.model.tables;

public class FormsTable extends AbstractDataTable {

	public static final String TAG = FormsTable.class.getSimpleName();

	// table name
	public static final String NAME = "Forms";

	// table columns
	public static final String COL_ID = "_id";
	public static final String COL_WEB_ID = "web_id";
	public static final String COL_SERVER = "server";
	public static final String COL_COMPANY_ID = "company_id";
	public static final String COL_NAME = "name";
	public static final String COL_WORKFLOW_ID = "workflow_id";
	public static final String COL_WEB_TABLE_NAME = "web_table_name";

	public static final String COL_FIELDS = "fields";
	public static final String COL_ON_CREATE_FIELDS_ENABLED = "on_create_fields_enabled";
	public static final String COL_ON_CREATE_FIELDS_REQUIRED = "on_create_fields_required";
	public static final String COL_ON_CREATE_FIELDS_HIDDEN = "on_create_fields_hidden";

	public static final String COL_BUTTONS = "buttons";
	public static final String COL_ACTIONS = "actions";

	public static final String COL_DOCUMENTS_LAST_SEARCH_UPDATES_DATE = "last_documents_update_search_date";
	public static final String COL_COMMENTS_LAST_SEARCH_UPDATES_DATE = "last_comments_update_search_date";

	@Override
	public String[] getTableColumns() {
		return new String[] { COL_ID, COL_WEB_ID, COL_SERVER, COL_COMPANY_ID, COL_NAME,
		        COL_WORKFLOW_ID, COL_WEB_TABLE_NAME, COL_FIELDS, COL_ON_CREATE_FIELDS_ENABLED,
		        COL_ON_CREATE_FIELDS_REQUIRED, COL_ON_CREATE_FIELDS_HIDDEN, COL_BUTTONS,
		        COL_ACTIONS, COL_DOCUMENTS_LAST_SEARCH_UPDATES_DATE,
		        COL_COMMENTS_LAST_SEARCH_UPDATES_DATE };
	}

	@Override
	protected String getCreateTableQuery() {
		// @formatter:off
		return "CREATE TABLE " + NAME + "("
				+ COL_ID 							+ " INTEGER PRIMARY KEY AUTOINCREMENT, "
				+ COL_WEB_ID 						+ " TEXT NOT NULL, "
				+ COL_SERVER 						+ " TEXT NOT NULL, "
				+ COL_COMPANY_ID 					+ " TEXT NOT NULL, "
				+ COL_NAME 							+ " TEXT NOT NULL, "
				+ COL_WORKFLOW_ID 					+ " TEXT NOT NULL, "
				+ COL_WEB_TABLE_NAME 				+ " TEXT NOT NULL, "
				+ COL_FIELDS 						+ " TEXT NOT NULL, "
				+ COL_ON_CREATE_FIELDS_ENABLED 		+ " TEXT NOT NULL, "
				+ COL_ON_CREATE_FIELDS_REQUIRED 	+ " TEXT NOT NULL, "
				+ COL_ON_CREATE_FIELDS_HIDDEN 		+ " TEXT NOT NULL, "
				+ COL_BUTTONS 						+ " TEXT NOT NULL, "
				+ COL_ACTIONS 						+ " TEXT NOT NULL,"
				+ COL_DOCUMENTS_LAST_SEARCH_UPDATES_DATE 	+ " TEXT, "
				+ COL_COMMENTS_LAST_SEARCH_UPDATES_DATE 	+ " TEXT "
				+ "); ";
		// @formatter:on		
	}

	@Override
	protected String getTableName() {
		return NAME;
	}

}
